#!/usr/bin/env bash

# Exit build script on first failure
set -e

# Echo commands to stdout.
set -x

if [ "$1" = "--skip-build" ]; then
  EXTRA_FLAGS=""
else
  EXTRA_FLAGS="--build"
fi
readonly EXTRA_FLAGS

# Exit on unset variable.
set -u

cd e2e
COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 \
  docker-compose up \
    --exit-code-from cypress \
    --abort-on-container-exit \
    ${EXTRA_FLAGS}
